package com.example.soss.controller;


import com.example.soss.annotation.OperationLog;
import com.example.soss.annotation.RefreshLimit;
import com.example.soss.entity.Student;
import com.example.soss.util.UserContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class IndexController {



    @RefreshLimit(maxCount = 3)
    @OperationLog("进入首页")
    @GetMapping({"/index", "/"})
    public String toIndex(Model model) {
        Student student = UserContextHolder.getUser();
        model.addAttribute("loginUser", student);
        return "index";
    }


    @OperationLog("跳转服务器错误页面")
    @GetMapping("/500")
    public String error() {
        return "error/500";
    }

    @OperationLog("跳转权限不足页面")
    @GetMapping("/403")
    public String denied() {
        return "error/403";
    }

    @OperationLog("跳转访问人数过多页面")
    @GetMapping("/401")
    public String accessLimit() {
        return "error/401";
    }


    @OperationLog("跳转点击太频繁页面")
    @GetMapping("/400")
    public String refreshLimit() {
        return "error/400";
    }
}
